home *** CD-ROM | disk | FTP | other *** search
- #include <libraries/feelin.h>
-
- #include <proto/exec.h>
- #include <proto/utility.h>
- #include <proto/feelin.h>
-
- #define UtilityBase FeelinBase -> Utility
-
- /// Header
- struct LocalObjectData
- {
- FAreaData *AreaData;
- FSignalHandler shnode;
- ULONG index;
- };
-
- /* Methods and Attributes for the custom class */
-
- #define FM_Trigger (FCCM_BASE + 0)
-
- #define FA_Delay (FCCA_BASE + 0)
-
- /* Some strings to display */
-
- static const char *LifeOfBrian[] =
- {
- "Cheer up, Brian. You know what they say.",
- "Some things in life are bad,",
- "They can really make you mad.",
- "Other things just make you swear and curse.",
- "When you're chewing on life's grissle,",
- "Don't grumble, give a whistle.",
- "And this'll help things turn out for the best,",
- "And...",
- "Always look on the bright side of life",
- "Always look on the light side of life",
- "If life seems jolly rotten,",
- "There's something you've forgotten,",
- "And that's to laugh, and smile, and dance, and sing.",
- "When you're feeling in the dumps,",
- "Don't be silly chumps,",
- "Just purse your lips and whistle, that's the thing.",
- "And...",
- "Always look on the bright side of life, come on!",
- "Always look on the right side of life",
- "For life is quite absurd,",
- "And death's the final word.",
- "You must always face the curtain with a bow.",
- "Forget about your sin,",
- "Give the audience a grin.",
- "Enjoy it, it's your last chance anyhow,",
- "So...",
- "Always look on the bright side of death",
- "Just before you draw your terminal breath.",
- "Life's a piece of shit,",
- "When you look at it.",
- "Life's a laugh, and death's a joke, it's true.",
- "You'll see it's all a show,",
- "Keep 'em laughing as you go,",
- "Just remember that the last laugh is on you.",
- "And...",
- "Always look on the bright side of life !",
- "...",
- "*** THE END ***",
- "",
- NULL,
- };
-
- //+
-
- /***************************************************************************/
- /* Here is the beginning of our new class... */
- /***************************************************************************/
-
- ///mNew
- F_METHOD(ULONG,mNew)
- {
- struct LocalObjectData *LOD = F_LOD(Class,Obj);
-
- LOD -> AreaData = (FAreaData *) F_Get(Obj,FA_AreaData);
-
- LOD -> shnode.Object = Obj;
- LOD -> shnode.Method = FM_Trigger;
- LOD -> shnode.Flags = FF_SignalHandler_Timer;
- LOD -> shnode.fsh_Secs = 0;
- LOD -> shnode.fsh_Micros = 500000;
-
- LOD -> index = 0;
-
- return F_SUPERDO();
- }
- //+
- ///mSet
- F_METHOD(ULONG,mSet)
- {
- struct LocalObjectData *LOD = F_LOD(Class,Obj);
- struct TagItem *Tags = Msg,
- *item;
-
- while (item = NextTagItem(&Tags))
- switch (item -> ti_Tag)
- {
- case FA_Delay:
- {
- if (FF_Area_CanDraw & _flags)
- {
- F_Do(_app,FM_Application_RemSignalHandler,&LOD -> shnode);
- LOD -> shnode.fsh_Micros = item -> ti_Data;
- F_Do(_app,FM_Application_AddSignalHandler,&LOD -> shnode);
- }
- else
- {
- LOD -> shnode.fsh_Micros = item -> ti_Data;
- }
- }
- break;
- }
-
- return F_SUPERDO();
- }
- //+
- ///mSetup
- F_METHOD(ULONG,mSetup)
- {
- struct LocalObjectData *LOD = F_LOD(Class,Obj);
-
- if (F_SUPERDO())
- {
- F_Do(_app,FM_Application_AddSignalHandler,&LOD -> shnode);
-
- return TRUE;
- }
- return FALSE;
- }
- //+
- ///mCleanup
- F_METHOD(ULONG,mCleanup)
- {
- struct LocalObjectData *LOD = F_LOD(Class,Obj);
-
- F_Do(_app,FM_Application_RemSignalHandler,&LOD -> shnode);
-
- return F_SUPERDO();
- }
- //+
- ///mTrigger
- F_METHOD(ULONG,mTrigger)
- {
- struct LocalObjectData *LOD = F_LOD(Class,Obj);
-
- F_Set(Obj,FA_Text,(ULONG)(LifeOfBrian[LOD -> index]));
-
- if (!LifeOfBrian[++LOD->index])
- {
- LOD -> index = 0;
- }
-
- return TRUE;
- }
- //+
-
- static struct FeelinMethodEntry Handlers[] =
- {
- mNew, NULL, FM_New,
- mSet, NULL, FM_Set,
- mSetup, NULL, FM_Setup,
- mCleanup, NULL, FM_Cleanup,
- mTrigger, NULL, FM_Trigger,
-
- NULL
- };
-
- /* Thats all there is about it. Now lets see how things are used... */
-
- struct FeelinBase *FeelinBase;
-
- void main(void)
- {
- FObject app,win,spd,my;
- struct FeelinClass *fcc;
-
- if (FeelinBase = (struct FeelinBase *) OpenLibrary("feelin.library",FV_VERSION))
- {
- if (fcc = F_CreateClass(FA_Class_Super, FC_Text,
- FA_Class_LODSize, sizeof (struct LocalObjectData),
- FA_Class_MethodsTable, Handlers,
- TAG_DONE))
- {
- app = ApplicationObject,
- FA_Application_Title, "SignalHandler_1",
- FA_Application_Version, "$VER: SignalHandler_1 1.0 (2004.05.19)",
- FA_Application_Copyright, "©2004, Olivier LAVIALE <olaviale@numericable.fr>",
- FA_Application_Author, "Stefan Stuntz",
- FA_Application_Description, "Demonstrate the use of custom classes.",
- FA_Application_Base, "SH_1",
-
- Child, win = WindowObject,
- FA_ID, MAKE_ID('S','H','_','1'),
- FA_Window_Title, "SignalHandler Class",
- FA_Window_Open, TRUE,
-
- Child, VGroup,
- Child, TextObject,
- TextFrame,
- FA_Back, "FP_Text_Back",
- FA_Text, "<align=center>Demonstration of a class that reacts on<br>events (here: timer signals) automatically.",
- FA_SetMax, FV_SetMaxH,
- End,
-
- Child, my = F_NewObj(fcc -> Name,
- TextFrame,
- FA_Text_PreParse, "<align=center>",
- FA_Text_VCenter, TRUE,
- End,
-
- Child, ColGroup(2),
- Child, TextObject,
- FA_Text, "Micros :",
- FA_SetMax, TRUE,
- DontChain,
- End,
- Child, spd = SliderA, TRUE,5000,1000000,50000,
- "FA_Numeric_Step", 1000,
- FA_ID, MAKE_ID('S','P','E','D'),
- FA_ContextHelp, "Adjust the number of micro seconds\nto wait between each string.",
- End,
- End,
- End,
- End,
- End;
-
- if (app)
- {
- F_Do(win,FM_Notify,FA_Window_CloseRequest,TRUE,app,FM_Application_Shutdown,0);
- F_Do(spd,FM_Notify,"FA_Numeric_Value",FV_Notify_Always,my,FM_Set,2,FA_Delay,FV_Notify_Value);
-
- F_Do(app,FM_Application_Run);
- F_DisposeObj(app);
- }
-
- F_DeleteClass(fcc);
- }
- CloseLibrary(FeelinBase);
- }
- }
-